package interface_layer;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import database_layer.Common;

/**
 * This class is a basic error handler, which parses the return value
 * and redirects accordingly. It was first used as a main error printer,
 * until we decided to move the error outputting to errorPage.jsp
 */
public class ErrorHandler
{
	public static void parseForErrors(int errorValue, HttpServletResponse response, String redirectPage)
	{
		try
		{
			switch(errorValue)
			{
				case Common.NO_ERROR:
					response.sendRedirect(redirectPage);
					break;
				default:
					response.sendRedirect("errorPage.jsp?error="+errorValue);
			}
		}
		catch (IOException e)
		{
			System.out.println("Experienced an IO error, can't output to user...");
		}
	}
}
